#!/bin/bash -xe

LINUX_KERNEL_DIR=code/linux_kernel
BUSYBOX_DIR=code/busybox
BASH_DIR=code/bash
ROOTFS_IMAGE=rootfs.cpio.gz

BUSYBOX_OLD_OUT_DIR=$BUSYBOX_DIR/_install
BUSYBOX_OUT_DIR=$BUSYBOX_DIR/_install.$ARCH
BASH_OUT_DIR=$BASH_DIR/build.$ARCH
ROOTFS_DIR=$ARCH/rootfs
MOUNT_DIR=$ARCH/mnt
MOUNT_TARGET=../../out/$ARCH/out
QEMU_BIN=qemu-system-$ARCH

if [ "$ARCH" = "arm" ]; then
    LINUX_KERNEL_IMAGE=$LINUX_KERNEL_DIR/arch/arm/boot/zImage
    LINUX_KERNEL_ARCH=arm
    LINUX_KERNEL_DEFCONFIG=vexpress_defconfig
    CONFIGURE_TOOLCHAIN=arm-linux-gnueabihf
    TOOLCHAIN=${CONFIGURE_TOOLCHAIN}-
    MACHINE_OPTION=type=virt,virtualization=true
    CPU_OPTION=""
fi

if [ "$ARCH" = "aarch64" ]; then
    LINUX_KERNEL_IMAGE=$LINUX_KERNEL_DIR/arch/arm64/boot/Image
    LINUX_KERNEL_ARCH=arm64
    LINUX_KERNEL_DEFCONFIG=defconfig
    CONFIGURE_TOOLCHAIN=aarch64-linux-gnu
    TOOLCHAIN=${CONFIGURE_TOOLCHAIN}-
    MACHINE_OPTION=type=virt,virtualization=true,gic-version=3
    CPU_OPTION="-cpu cortex-a57"
fi
